import App from './App'

import {
	createSSRApp
} from 'vue'

export function createApp() {
	const app = createSSRApp(App)
	app.config.globalProperties.routerBack = (times = 0) => {
		let pages = getCurrentPages()
		// 有可返回的页面则直接返回
		if (pages.length > 1) {
			uni.navigateBack()
			return
		}
		// 返回home页面
		uni.reLaunch({ url: "/pages/index/index" })
		return
	}
	
	app.config.globalProperties.routerWallet = (times = 0) => {
		// 跳转钱包页面
		uni.switchTab({
			url: '/pages/wallet/index'
		});
		return
	}
	app.config.globalProperties.routerCustomer = (times = 0) => {
		// 跳转客服页面
		uni.switchTab({
			url: '/pages/im/im'
		});
		return
	}
	
	app.config.globalProperties.toPath = (path) => {
		// 跳转页面
		uni.navigateTo({
			url: path
		});
		return
	}
	return {
		app
	}
}
